package com.example.shopping_web_back.service;

import com.example.shopping_web_back.mapper.GoodsImagesMapper;
import com.example.shopping_web_back.pojo.GoodsImages;
import com.example.shopping_web_back.service.impl.GoodsImagesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsImagesService implements GoodsImagesServiceImpl {

    @Autowired
    private GoodsImagesMapper goodsImagesMapper;

    @Override
    public void addGoodsImages(Integer id, String goodsImage) {
        goodsImagesMapper.addGoodsImages(id, goodsImage);
    }

    @Override
    public void deleteGoodsImages(String goodsImage) {
        goodsImagesMapper.deleteGoodsImages(goodsImage);
    }

    @Override
    public void changeGoodsImages(GoodsImages oldGoodsImages, GoodsImages newGoodsImages) {
        String oldGoodsImages1 = oldGoodsImages.getGoodsImage();
        String newGoodsImages1 = newGoodsImages.getGoodsImage();
        Integer ID = newGoodsImages.getGoodsId();
        goodsImagesMapper.changeGoodsImages(oldGoodsImages1, newGoodsImages1, ID);
    }

    @Override
    public List<GoodsImages> getGoodsImages(Integer id) {
        return goodsImagesMapper.getGoodsImages(id);
    }
}
